#include "data_global.h"
#include "data_global.c"
//#include "sqlite_link_list.h"
typedef int datatype_t;

//创建单链表
slinklist sqlite_CreateEmptyLinklist()
{
    slinklist h = (slinklist)malloc(sizeof(slinknode));
    h->next = NULL;
    return h;
}

//为空返回1
int sqlite_EmptyLinklist(slinklist h)
{
    if(h->next == NULL)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

slinklist sqlite_GetLinknode (slinklist h)
{
    return h->next;
}

void sqlite_dellinknode(slinklist h)
{
    slinklist temp;
    temp = h->next;
    h->next = temp->next;
    free(temp);
}
int sqlite_InsertLinknode(slinklist h, struct env_info_clien_addr y,\
                          int storageNum_l, int goodsKinds_l)
{
    slinklist temp = (slinklist)malloc(sizeof(slinknode));
    temp->storageNum = storageNum_l;
    temp->goodsKinds = goodsKinds_l;
    temp->data_link = y;
    while(h->next != NULL)
    {
        h = h->next;
    }
    h->next = temp;
    temp->next = NULL;
    return 1;
}


int linklist_show(slinklist h)
{
    while(h->next != NULL)
    {
        h = h->next;
        printf("%d\n",h->storageNum);
    }
    return 0;
}

void setLimit (int sto_no, float temMAX, float temMIN, float humMAX, float humMIN, float illMAX, float illMIN)
{
    if (sto_no >= 0 && (sto_no <=STORAGE_NUM - 1))
    {
        slinkHead->data_link.storage_no[sto_no].storage_num = sto_no;
        slinkHead->data_link.storage_no[sto_no].temperatureMAX = temMAX;
        slinkHead->data_link.storage_no[sto_no].temperatureMIN = temMIN;
        slinkHead->data_link.storage_no[sto_no].humidityMAX = humMAX;
        slinkHead->data_link.storage_no[sto_no].humidityMIN = humMIN;
        slinkHead->data_link.storage_no[sto_no].illuminationMAX = illMAX;
        slinkHead->data_link.storage_no[sto_no].illuminationMIN = illMIN;
    }
}

